package name.matthewgreet.example5.action; import java.util.List; import javax.servlet.http.HttpSession; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import com.opensymphony.xwork2.ActionSupport; import name.matthewgreet.example5.common.AbstractFormDrivenActionSupport; import name.matthewgreet.example5.common.ListCache; import name.matthewgreet.example5.common.ListFinder; import name.matthewgreet.example5.common.NA; import name.matthewgreet.example5.dto.GameDTO; import name.matthewgreet.example5.form.GameFamilyForm; import name.matthewgreet.example5.model.GameTable; import name.matthewgreet.example5.model.Model; import name.matthewgreet.example5.model.GameTable.GameOption; import name.matthewgreet.example5.util.GameCompositeCache; /** * Finds board games by overall ranking or ranking of a category. */ @InterceptorRef("FormDrivenStack") @Results({ @Result(name=ActionSupport.INPUT, type="redirectAction", params = {"namespace", "/", "actionName", "ViewGameList"}), @Result(name=ActionSupport.SUCCESS, type="redirectAction", params = {"namespace", "/", "actionName", "ViewGameList"}) }) public class FindGameListByFamilyAction extends AbstractFormDrivenActionSupport<GameFamilyForm> { public static class GameListFinderByFamily implements ListFinder<NA,GameDTO> { private static final long serialVersionUID = 6409312894523453002L; private String family; public GameListFinderByFamily(String family) { this.family = family; } @Override public List<GameDTO> getList(NA selectedMaster) throws Exception { GameTable gameTable; gameTable = Model.getInstance().getGameTable(); return gameTable.findByFamily(family, GameOption.DESIGNERS); } public String getFamily() { return family; } } private static final long serialVersionUID = -7979376337555804889L; @Action("/FindGameListByFamily") @Override public String execute() throws Exception { GameFamilyForm form; ListCache<NA,Integer,GameDTO> listCache; HttpSession session; form = getModel(); session = getRequest().getSession(); listCache = GameCompositeCache.getInstance(session).getMasterListCache(); listCache.setListFinder(new GameListFinderByFamily(form.getFamily())); return SUCCESS; } @Override protected GameFamilyForm makeForm() { return new GameFamilyForm(); } }